#include <stdio.h>

/*
 * 继承
 */

class object
{
	public:
			int color;
			object() {}
			object(int color) {
				this->color = color;
			}
			void print_color() {
				printf("color=%d\n", color);
			}
};

class box:public object
{
	private:
			int width, height, depth;
	public:
			box(int color, int width, int height, int depth)
			{
				this->color = color;
				this->width = width;
				this->height = height;
				this->depth = depth;
			}

			void dump()
			{
				printf("this is box, color=%d, width=%d, height=%d, depth=%d\n", color, width, height, depth);
			}
};

class sphere:public object
{
	private:
			int radius;
	public:
			sphere(int color, int radius)
			{
				this->color = color;
				this->radius = radius;
			}

			void dump()
			{
				printf("this is sphere.color=%d, radius=%d\n", color, radius);
			}
};

int main()
{
	box b(1, 10, 20, 30);
	sphere s(2, 40);

	b.print_color();
	s.print_color();

	b.dump();
	s.dump();

	return 0;
}


#if 0


/* gcc */
	GCC不会使用ECX传递this指针，它会以函数的第一个参数的传递方式传递this指针。

#endif

#if 0
/*
 * intel
 */
0000000000001169 <main>:
    1169:	f3 0f 1e fa          	endbr64 
    116d:	55                   	push   %rbp
    116e:	48 89 e5             	mov    %rsp,%rbp
    1171:	48 83 ec 30          	sub    $0x30,%rsp
    1175:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    117c:	00 00 
    117e:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
    1182:	31 c0                	xor    %eax,%eax
    1184:	48 8d 45 e0          	lea    -0x20(%rbp),%rax
    1188:	41 b8 1e 00 00 00    	mov    $0x1e,%r8d
    118e:	b9 14 00 00 00       	mov    $0x14,%ecx
    1193:	ba 0a 00 00 00       	mov    $0xa,%edx
    1198:	be 01 00 00 00       	mov    $0x1,%esi
    119d:	48 89 c7             	mov    %rax,%rdi
    11a0:	e8 9d 00 00 00       	callq  1242 <_ZN3boxC1Eiiii>
    11a5:	48 8d 45 d8          	lea    -0x28(%rbp),%rax
    11a9:	ba 28 00 00 00       	mov    $0x28,%edx
    11ae:	be 02 00 00 00       	mov    $0x2,%esi
    11b3:	48 89 c7             	mov    %rax,%rdi
    11b6:	e8 1f 01 00 00       	callq  12da <_ZN6sphereC1Eii>
    11bb:	48 8d 45 e0          	lea    -0x20(%rbp),%rax
    11bf:	48 89 c7             	mov    %rax,%rdi
    11c2:	e8 4f 00 00 00       	callq  1216 <_ZN6object11print_colorEv>
    11c7:	48 8d 45 d8          	lea    -0x28(%rbp),%rax
    11cb:	48 89 c7             	mov    %rax,%rdi
    11ce:	e8 43 00 00 00       	callq  1216 <_ZN6object11print_colorEv>
    11d3:	48 8d 45 e0          	lea    -0x20(%rbp),%rax
    11d7:	48 89 c7             	mov    %rax,%rdi
    11da:	e8 b7 00 00 00       	callq  1296 <_ZN3box4dumpEv>
    11df:	48 8d 45 d8          	lea    -0x28(%rbp),%rax
    11e3:	48 89 c7             	mov    %rax,%rdi
    11e6:	e8 27 01 00 00       	callq  1312 <_ZN6sphere4dumpEv>
    11eb:	b8 00 00 00 00       	mov    $0x0,%eax
    11f0:	48 8b 4d f8          	mov    -0x8(%rbp),%rcx
    11f4:	64 48 33 0c 25 28 00 	xor    %fs:0x28,%rcx
    11fb:	00 00 
    11fd:	74 05                	je     1204 <main+0x9b>
    11ff:	e8 5c fe ff ff       	callq  1060 <__stack_chk_fail@plt>
    1204:	c9                   	leaveq 
    1205:	c3                   	retq   

0000000000001206 <_ZN6objectC1Ev>:
    1206:	f3 0f 1e fa          	endbr64 
    120a:	55                   	push   %rbp
    120b:	48 89 e5             	mov    %rsp,%rbp
    120e:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)
    1212:	90                   	nop
    1213:	5d                   	pop    %rbp
    1214:	c3                   	retq   
    1215:	90                   	nop

0000000000001216 <_ZN6object11print_colorEv>:
    1216:	f3 0f 1e fa          	endbr64 
    121a:	55                   	push   %rbp
    121b:	48 89 e5             	mov    %rsp,%rbp
    121e:	48 83 ec 10          	sub    $0x10,%rsp
    1222:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)
    1226:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    122a:	8b 00                	mov    (%rax),%eax
    122c:	89 c6                	mov    %eax,%esi
    122e:	48 8d 3d d3 0d 00 00 	lea    0xdd3(%rip),%rdi        # 2008 <_IO_stdin_used+0x8>
    1235:	b8 00 00 00 00       	mov    $0x0,%eax
    123a:	e8 31 fe ff ff       	callq  1070 <printf@plt>
    123f:	90                   	nop
    1240:	c9                   	leaveq 
    1241:	c3                   	retq   

0000000000001242 <_ZN3boxC1Eiiii>:
    1242:	f3 0f 1e fa          	endbr64 
    1246:	55                   	push   %rbp
    1247:	48 89 e5             	mov    %rsp,%rbp
    124a:	48 83 ec 20          	sub    $0x20,%rsp
    124e:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)
    1252:	89 75 f4             	mov    %esi,-0xc(%rbp)
    1255:	89 55 f0             	mov    %edx,-0x10(%rbp)
    1258:	89 4d ec             	mov    %ecx,-0x14(%rbp)
    125b:	44 89 45 e8          	mov    %r8d,-0x18(%rbp)
    125f:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    1263:	48 89 c7             	mov    %rax,%rdi
    1266:	e8 9b ff ff ff       	callq  1206 <_ZN6objectC1Ev>
    126b:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    126f:	8b 55 f4             	mov    -0xc(%rbp),%edx
    1272:	89 10                	mov    %edx,(%rax)
    1274:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    1278:	8b 55 f0             	mov    -0x10(%rbp),%edx
    127b:	89 50 04             	mov    %edx,0x4(%rax)
    127e:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    1282:	8b 55 ec             	mov    -0x14(%rbp),%edx
    1285:	89 50 08             	mov    %edx,0x8(%rax)
    1288:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    128c:	8b 55 e8             	mov    -0x18(%rbp),%edx
    128f:	89 50 0c             	mov    %edx,0xc(%rax)
    1292:	90                   	nop
    1293:	c9                   	leaveq 
    1294:	c3                   	retq   
    1295:	90                   	nop

0000000000001296 <_ZN3box4dumpEv>:
    1296:	f3 0f 1e fa          	endbr64 
    129a:	55                   	push   %rbp
    129b:	48 89 e5             	mov    %rsp,%rbp
    129e:	48 83 ec 10          	sub    $0x10,%rsp
    12a2:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)
    12a6:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    12aa:	8b 70 0c             	mov    0xc(%rax),%esi
    12ad:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    12b1:	8b 48 08             	mov    0x8(%rax),%ecx
    12b4:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    12b8:	8b 50 04             	mov    0x4(%rax),%edx
    12bb:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    12bf:	8b 00                	mov    (%rax),%eax
    12c1:	41 89 f0             	mov    %esi,%r8d
    12c4:	89 c6                	mov    %eax,%esi
    12c6:	48 8d 3d 4b 0d 00 00 	lea    0xd4b(%rip),%rdi        # 2018 <_IO_stdin_used+0x18>
    12cd:	b8 00 00 00 00       	mov    $0x0,%eax
    12d2:	e8 99 fd ff ff       	callq  1070 <printf@plt>
    12d7:	90                   	nop
    12d8:	c9                   	leaveq 
    12d9:	c3                   	retq   

00000000000012da <_ZN6sphereC1Eii>:
    12da:	f3 0f 1e fa          	endbr64 
    12de:	55                   	push   %rbp
    12df:	48 89 e5             	mov    %rsp,%rbp
    12e2:	48 83 ec 10          	sub    $0x10,%rsp
    12e6:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)
    12ea:	89 75 f4             	mov    %esi,-0xc(%rbp)
    12ed:	89 55 f0             	mov    %edx,-0x10(%rbp)
    12f0:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    12f4:	48 89 c7             	mov    %rax,%rdi
    12f7:	e8 0a ff ff ff       	callq  1206 <_ZN6objectC1Ev>
    12fc:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    1300:	8b 55 f4             	mov    -0xc(%rbp),%edx
    1303:	89 10                	mov    %edx,(%rax)
    1305:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    1309:	8b 55 f0             	mov    -0x10(%rbp),%edx
    130c:	89 50 04             	mov    %edx,0x4(%rax)
    130f:	90                   	nop
    1310:	c9                   	leaveq 
    1311:	c3                   	retq   

0000000000001312 <_ZN6sphere4dumpEv>:
    1312:	f3 0f 1e fa          	endbr64 
    1316:	55                   	push   %rbp
    1317:	48 89 e5             	mov    %rsp,%rbp
    131a:	48 83 ec 10          	sub    $0x10,%rsp
    131e:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)
    1322:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    1326:	8b 50 04             	mov    0x4(%rax),%edx
    1329:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    132d:	8b 00                	mov    (%rax),%eax
    132f:	89 c6                	mov    %eax,%esi
    1331:	48 8d 3d 18 0d 00 00 	lea    0xd18(%rip),%rdi        # 2050 <_IO_stdin_used+0x50>
    1338:	b8 00 00 00 00       	mov    $0x0,%eax
    133d:	e8 2e fd ff ff       	callq  1070 <printf@plt>
    1342:	90                   	nop
    1343:	c9                   	leaveq 
    1344:	c3                   	retq   
    1345:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
    134c:	00 00 00 
    134f:	90                   	nop

/*
 * arm
 */
000000000040062c <main>:
  40062c:	a9bd7bfd 	stp	x29, x30, [sp, #-48]!
  400630:	910003fd 	mov	x29, sp
  400634:	910083a0 	add	x0, x29, #0x20
  400638:	528003c4 	mov	w4, #0x1e                  	// #30
  40063c:	52800283 	mov	w3, #0x14                  	// #20
  400640:	52800142 	mov	w2, #0xa                   	// #10
  400644:	52800021 	mov	w1, #0x1                   	// #1
  400648:	94000020 	bl	4006c8 <_ZN3boxC1Eiiii>
  40064c:	910063a0 	add	x0, x29, #0x18
  400650:	52800502 	mov	w2, #0x28                  	// #40
  400654:	52800041 	mov	w1, #0x2                   	// #2
  400658:	94000045 	bl	40076c <_ZN6sphereC1Eii>
  40065c:	910083a0 	add	x0, x29, #0x20
  400660:	9400000f 	bl	40069c <_ZN6object11print_colorEv>
  400664:	910063a0 	add	x0, x29, #0x18
  400668:	9400000d 	bl	40069c <_ZN6object11print_colorEv>
  40066c:	910083a0 	add	x0, x29, #0x20
  400670:	9400002e 	bl	400728 <_ZN3box4dumpEv>
  400674:	910063a0 	add	x0, x29, #0x18
  400678:	9400004d 	bl	4007ac <_ZN6sphere4dumpEv>
  40067c:	52800000 	mov	w0, #0x0                   	// #0
  400680:	a8c37bfd 	ldp	x29, x30, [sp], #48
  400684:	d65f03c0 	ret

0000000000400688 <_ZN6objectC1Ev>:
  400688:	d10043ff 	sub	sp, sp, #0x10
  40068c:	f90007e0 	str	x0, [sp, #8]
  400690:	d503201f 	nop
  400694:	910043ff 	add	sp, sp, #0x10
  400698:	d65f03c0 	ret

000000000040069c <_ZN6object11print_colorEv>:
  40069c:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  4006a0:	910003fd 	mov	x29, sp
  4006a4:	f9000fa0 	str	x0, [x29, #24]
  4006a8:	f9400fa0 	ldr	x0, [x29, #24]
  4006ac:	b9400001 	ldr	w1, [x0]
  4006b0:	90000000 	adrp	x0, 400000 <_init-0x4b8>
  4006b4:	91224000 	add	x0, x0, #0x890
  4006b8:	97ffff9a 	bl	400520 <printf@plt>
  4006bc:	d503201f 	nop
  4006c0:	a8c27bfd 	ldp	x29, x30, [sp], #32
  4006c4:	d65f03c0 	ret

00000000004006c8 <_ZN3boxC1Eiiii>:
  4006c8:	a9bd7bfd 	stp	x29, x30, [sp, #-48]!
  4006cc:	910003fd 	mov	x29, sp
  4006d0:	f90017a0 	str	x0, [x29, #40]
  4006d4:	b90027a1 	str	w1, [x29, #36]
  4006d8:	b90023a2 	str	w2, [x29, #32]
  4006dc:	b9001fa3 	str	w3, [x29, #28]
  4006e0:	b9001ba4 	str	w4, [x29, #24]
  4006e4:	f94017a0 	ldr	x0, [x29, #40]
  4006e8:	97ffffe8 	bl	400688 <_ZN6objectC1Ev>
  4006ec:	f94017a0 	ldr	x0, [x29, #40]
  4006f0:	b94027a1 	ldr	w1, [x29, #36]
  4006f4:	b9000001 	str	w1, [x0]
  4006f8:	f94017a0 	ldr	x0, [x29, #40]
  4006fc:	b94023a1 	ldr	w1, [x29, #32]
  400700:	b9000401 	str	w1, [x0, #4]
  400704:	f94017a0 	ldr	x0, [x29, #40]
  400708:	b9401fa1 	ldr	w1, [x29, #28]
  40070c:	b9000801 	str	w1, [x0, #8]
  400710:	f94017a0 	ldr	x0, [x29, #40]
  400714:	b9401ba1 	ldr	w1, [x29, #24]
  400718:	b9000c01 	str	w1, [x0, #12]
  40071c:	d503201f 	nop
  400720:	a8c37bfd 	ldp	x29, x30, [sp], #48
  400724:	d65f03c0 	ret

0000000000400728 <_ZN3box4dumpEv>:
  400728:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  40072c:	910003fd 	mov	x29, sp
  400730:	f9000fa0 	str	x0, [x29, #24]
  400734:	f9400fa0 	ldr	x0, [x29, #24]
  400738:	b9400001 	ldr	w1, [x0]
  40073c:	f9400fa0 	ldr	x0, [x29, #24]
  400740:	b9400402 	ldr	w2, [x0, #4]
  400744:	f9400fa0 	ldr	x0, [x29, #24]
  400748:	b9400803 	ldr	w3, [x0, #8]
  40074c:	f9400fa0 	ldr	x0, [x29, #24]
  400750:	b9400c04 	ldr	w4, [x0, #12]
  400754:	90000000 	adrp	x0, 400000 <_init-0x4b8>
  400758:	91228000 	add	x0, x0, #0x8a0
  40075c:	97ffff71 	bl	400520 <printf@plt>
  400760:	d503201f 	nop
  400764:	a8c27bfd 	ldp	x29, x30, [sp], #32
  400768:	d65f03c0 	ret

000000000040076c <_ZN6sphereC1Eii>:
  40076c:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  400770:	910003fd 	mov	x29, sp
  400774:	f9000fa0 	str	x0, [x29, #24]
  400778:	b90017a1 	str	w1, [x29, #20]
  40077c:	b90013a2 	str	w2, [x29, #16]
  400780:	f9400fa0 	ldr	x0, [x29, #24]
  400784:	97ffffc1 	bl	400688 <_ZN6objectC1Ev>
  400788:	f9400fa0 	ldr	x0, [x29, #24]
  40078c:	b94017a1 	ldr	w1, [x29, #20]
  400790:	b9000001 	str	w1, [x0]
  400794:	f9400fa0 	ldr	x0, [x29, #24]
  400798:	b94013a1 	ldr	w1, [x29, #16]
  40079c:	b9000401 	str	w1, [x0, #4]
  4007a0:	d503201f 	nop
  4007a4:	a8c27bfd 	ldp	x29, x30, [sp], #32
  4007a8:	d65f03c0 	ret

00000000004007ac <_ZN6sphere4dumpEv>:
  4007ac:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  4007b0:	910003fd 	mov	x29, sp
  4007b4:	f9000fa0 	str	x0, [x29, #24]
  4007b8:	f9400fa0 	ldr	x0, [x29, #24]
  4007bc:	b9400001 	ldr	w1, [x0]
  4007c0:	f9400fa0 	ldr	x0, [x29, #24]
  4007c4:	b9400402 	ldr	w2, [x0, #4]
  4007c8:	90000000 	adrp	x0, 400000 <_init-0x4b8>
  4007cc:	91236000 	add	x0, x0, #0x8d8
  4007d0:	97ffff54 	bl	400520 <printf@plt>
  4007d4:	d503201f 	nop
  4007d8:	a8c27bfd 	ldp	x29, x30, [sp], #32
  4007dc:	d65f03c0 	ret


#endif

